home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / online / motor.EXE / SIRA.PAS < prev    next >
Pascal/Delphi Source File  |  1991-10-05  |  8KB  |  220 lines

  1. begin
  2. write('ѥ');
  3. end.
  4. cord
  5.       x1,y1,x2,y2,group:integer;
  6.     end;
  7.    poin=record
  8.          x,y :longint;
  9.          index:string[10];
  10.    end;
  11.      points=array [1..2200] of poin;
  12.  
  13. var
  14.    m,min,miny: integer;
  15.    point:points;
  16.    f1,f2,f3,f4,f5 :text;
  17.    number:integer;
  18.    count:integer;
  19.    getx,gety    :integer;
  20.    counth,countv:integer;
  21.    x1limit,x2limit,y1limit,y2limit :integer;
  22.    i,j,d1,d2 :integer;
  23.    rec   :string[10];
  24.    ylocation,xlocation :integer;
  25.    x1,x2,y1,y2 :string[5];
  26.    temp:real;
  27.    groupv,grouph :longint;
  28.    grdriver,grmode :integer;
  29.    horz,ver,lines:array[1..200] of lin;
  30.    str2,str1,s   :string;
  31.    temp1 :real;
  32.    label 10,20,30;
  33.  
  34.    procedure quicksort(var a: points; Lo,Hi: integer);
  35.  
  36.              procedure sort(l,r: integer);
  37.                        var
  38.                           i,j:integer;
  39.                           x,y: string[10];
  40.                           xp,yp :poin;
  41.                        begin
  42.                             i:=l; j:=r; x:=a[(l+r) DIV 2].index;
  43.                               repeat
  44.                                   while a[i].index<x do i:=i+1;
  45.                                       while x<a[j].index do j:=j-1;
  46.                                           if i<=j then
  47.                                               begin
  48.                                                     yp:=a[i];
  49.                                                     a[i]:=a[j];
  50.                                                     a[j]:=yp;
  51.                                                     i:=i+1; j:=j-1;
  52.                                               end;
  53.                                           until i>j;
  54.                                     if l<j then sort(l,j);
  55.                                     if i<r then sort(i,r);
  56.                                   end;
  57.  
  58.                             begin {quicksort};
  59.                               sort(Lo,Hi);
  60.                             end;
  61.  
  62.  
  63.    begin
  64.         min:=29999;
  65.         miny:=29999;
  66.         assign(f5,'dosya.dat');reset(f5);readln(f5,s);
  67.         assign(f1,s+'.dxf');
  68.         reset(f1);
  69.         str2:='';
  70.         count:=0;
  71.         {****** READLN ****}
  72.         {****** READLN ****}
  73.         {****** READLN ****}
  74.          while str2 <> 'ENDSEC' do
  75.                begin
  76.                     readln(f1,str2);
  77.                     if str2='ENTITIES' then
  78.                        begin
  79.                             readln(f1,str2);
  80.                             rec:='start';
  81.                        end;
  82.                     if rec='start' then
  83.                        begin
  84.                             readln(f1,str2);
  85.                             if str2='LINE' then
  86.                                begin
  87.                                     count:=count+1;
  88.                                     readln(f1,str2);
  89.                                     readln(f1,str2);
  90.                                     readln(f1,str2);
  91.                                     readln(f1,x1);
  92.                                     readln(f1,str2);
  93.                                     readln(f1,y1);
  94.                                     readln(f1,str2);
  95.                                     readln(f1,x2);
  96.                                     readln(f1,str2);
  97.                                     readln(f1,y2);
  98.                                     val(x1,lines[count].x1,i);
  99.                                     val(y1,lines[count].y1,i);
  100.                                     val(x2,lines[count].x2,i);
  101.                                     val(y2,lines[count].y2,i);
  102.  
  103.                                end;
  104.  
  105.                end;
  106.                
  107.          end;
  108.          counth:=0;
  109.          countv:=0;
  110.          for d1:=1 to count do
  111.              begin
  112.                   if (lines[d1].x1-lines[d1].x2)=0 then
  113.                      begin
  114.                        countv:=countv+1;
  115.                        ver[countv].x1:=lines[d1].x1;
  116.                        ver[countv].y1:=lines[d1].y1;
  117.                        ver[countv].x2:=lines[d1].x2;
  118.                        ver[countv].y2:=lines[d1].y2;
  119.                      end;
  120.                   if (lines[d1].y1-lines[d1].y2)= 0 then
  121.                       begin
  122.                        counth:=counth+1;
  123.                        horz[counth].x1:=lines[d1].x1;
  124.                        horz[counth].y1:=lines[d1].y1;
  125.                        horz[counth].x2:=lines[d1].x2;
  126.                        horz[counth].y2:=lines[d1].y2;
  127.                      end;
  128.              end;
  129.              {******Points******}
  130.              i:=0;
  131.              assign(f3,'sira.dat');
  132.              rewrite(f3);
  133.              for d2:=1 to counth do
  134.              begin
  135.                   for d1:=1 to countv do
  136.                       begin
  137.                            if (ver[d1].y2 > ver[d1].y1) and (horz[d2].x2 > horz[d2].x1)  then
  138.                            if (ver[d1].x1 >= horz[d2].x1) and (ver[d1].x1 <= horz[d2]. x2 ) and
  139.                            (horz[d2].y1 >= ver[d1].y1) and (horz[d2].y1 <=ver[d1].y2) then
  140.                              begin
  141.                                i:=i+1;
  142.                                point[i].x:=ver[d1].x1;
  143.                                point[i].y:=horz[d2].y1;
  144.                              end;
  145.                            if (ver[d1].y2 < ver[d1].y1) and (horz[d2].x2 > horz[d2].x1)  then
  146.                            if (ver[d1].x1 >= horz[d2].x1) and (ver[d1].x1 <= horz[d2]. x2 ) and
  147.                            (horz[d2].y1 <= ver[d1].y1) and (horz[d2].y1 >=ver[d1].y2) then
  148.                              begin
  149.                                i:=i+1;
  150.                                point[i].x:=ver[d1].x1;
  151.                                point[i].y:=horz[d2].y1;
  152.                              end;
  153.  
  154.                              if (ver[d1].y2 > ver[d1].y1) and (horz[d2].x2 < horz[d2].x1)  then
  155.                            if (ver[d1].x1 <= horz[d2].x1) and (ver[d1].x1 >= horz[d2]. x2 ) and
  156.                            (horz[d2].y1 >= ver[d1].y1) and (horz[d2].y1 <=ver[d1].y2) then
  157.                              begin
  158.  
  159.                                i:=i+1;
  160.                                point[i].x:=ver[d1].x1;
  161.                                point[i].y:=horz[d2].y1;
  162.                              end;
  163.                              if (ver[d1].y2 < ver[d1].y1) and (horz[d2].x2 < horz[d2].x1)  then
  164.                            if (ver[d1].x1 <= horz[d2].x1) and (ver[d1].x1 >= horz[d2]. x2 ) and
  165.                            (horz[d2].y1 <= ver[d1].y1) and (horz[d2].y1 >=ver[d1].y2) then
  166.                              begin
  167.                                i:=i+1;
  168.                                point[i].x:=ver[d1].x1;
  169.                                point[i].y:=horz[d2].y1;
  170.                                if point[i].x  < min then
  171.                                 min:=point[i].x;
  172.                                 if point[i].y  < miny then
  173.                                 miny:=point[i].y;
  174.                              end;
  175.  
  176.                       end;
  177.                   end;
  178.                  begin;
  179.                  i:=1;
  180.                  m:=1;
  181.                  30: writeln(f3,m,' ',point[i].x,' ',point[i].y);
  182.                   i:=m+1;
  183.                   m:=m+1;
  184.                   if not (point[i].x = 0) and not (point[i].y = 0) then goto 30;
  185.                   end;
  186.                   close(f3);
  187.                   str(counth,str1);
  188.                   {******INDEX VARIABLE******}
  189.                   for j:=1 to i do
  190.                       begin
  191.                            temp:=((point[j].y-miny)*10000+(point[j].x-min));
  192.                            str(temp:6:3,str1);
  193.                            point[j].index:=str1;
  194.                       end;
  195.                       quicksort(point,1,i);
  196.          for d1:=1 to count do
  197.              begin
  198.              end;
  199.          for d1:=1 to i do
  200.              begin
  201.                   str(d1,str1);
  202.  
  203.              end;
  204.          close(f1);
  205.     
  206.          end.uses crt;
  207. type
  208.     lin=record
  209.       x1,y1,x2,y2,group:integer;
  210.     end;
  211.    poin=record
  212.          x,y :longint;
  213.          index:string[10];
  214.    end;
  215.      points=array [1..2200] of poin;
  216.  
  217. var
  218.    m,min,miny: integer;
  219.    point:points;
  220.    f1,f2,f3,f4